package im.yisme.server.servlet;

import java.io.IOException;

import im.yisme.server.database.PlatformData;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;

public class EvaluateServlet extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 7706421097771100980L;
	
	public void doGet(HttpServletRequest request, HttpServletResponse response){
		doPost(request, response);
	}
	
	public void doPost(HttpServletRequest request, HttpServletResponse response){
		CharacterEncoding.setCharacterEncoding(request, response);
		
		String idString = request.getParameter("remoteId");
		String scoreString = request.getParameter("score");
		Long remoteId = Long.parseLong(idString);
		int score = Integer.parseInt(scoreString);
		
		new PlatformData().Evaluate(remoteId, score);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("flag", true);
		try {
			response.getWriter().print(jsonObject.toJSONString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
